package zoo.qboard.user.controller;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import zoo.productqnareplyboard.admin.domain.AdminProductReplyBoardCommand;
import zoo.qboard.dao.QboardDao;
import zoo.qboard.domain.QboardCommand;



@Controller
public class QboardDetailController {
	private static Log log = LogFactory.getLog(QboardDetailController.class);
	
	private QboardDao qboardDao;
	
	@Autowired
	public void setMemberService(QboardDao qboardDao) {
		this.qboardDao = qboardDao;
	}

	@RequestMapping("/main/boardqnadetail.do")
	public ModelAndView process(@RequestParam("bq_num") int bq_num) {

		if (log.isDebugEnabled()) {
			log.debug("qboardService : " + qboardDao);
		}
		
		qboardDao.updateHitq(bq_num);
		
		//문의 내용
		QboardCommand qboard = null;
		qboard = qboardDao.selectQBoard(bq_num);
		
		//댓글 
		List<AdminProductReplyBoardCommand> list = null;
		list = qboardDao.qreyList(bq_num);		
		
		System.out.println("리스트 ="+list);
		
		ModelAndView mav = new ModelAndView();
		mav.setViewName("qboarddetail");
		mav.addObject("qboarddetail",qboard);
		mav.addObject("list",list);
	
		return mav;
	}
}
